<?php

class CacheSlotsAbstract
{

    private $_id;
    private $_data;
    private $_lifetime;
    private $_dependency;

    public function __construct($id, $data = null, $lifetime = 0, $dependency = null)
    {
	$this->_id = $id;
	$this->_data = $data;
	$this->_lifetime = $lifetime;
	$this->_dependency = $dependency;
    }

    public function load()
    {
	if (!$this->_id) {
	    return false;
	}
	return CacheManager::getCache('memcache')->get($this->_id);
    }

    public function setData($data)
    {
	$this->_data = $data;
	return $this;
    }

    public function save()
    {
	if (!$this->_id) {
	    return false;
	}

	CacheManager::getCache('memcache')->set($this->_id, $this->_data, $this->_lifetime, $this->_dependency);
    }

    public function delete()
    {
	if (!$this->_id) {
	    return false;
	}
	CacheManager::getCache('memcache')->delete($this->_id);
    }

    public function getId()
    {
	return $this->_id;
    }

}

?>
